// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.asm;

import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.tree.ClassNode;

/**
 * Supplier of classes.
 * 
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public abstract class ClassSupplier {
  /**
   * Supplies a class and accepts given visitor on it.
   * 
   * @param visitor class visitor to accept on supplied class.
   */
  public abstract void accept(ClassVisitor visitor);
  
  /**
   * Returns supplier of given class node.
   * 
   * @param classNode class node to supply
   * @return supplier of given class node
   */
  public static ClassSupplier of(final ClassNode classNode) {
    return new ClassSupplier() {
      @Override
      public void accept(ClassVisitor visitor) {
        classNode.accept(visitor);
      }
    };
  }
}
